﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Configuration;
using System.Data;
using System.Data.SqlClient;


using Galaxy.Vinder.BO;

namespace Galaxy.Vinder.DAL
{
    public class ServicioDB
    {

        private static String connectionString = AppConfiguration.ConnectionString;

        public static Servicio getServicio(int id)
        {
            Servicio servicio = null;
            //String cmd = "select t.id a, t.titulo b, t.descripcion c, s.id d, s.nombre e, s.descripcion f, s.imagen g " + 
            //"from tip t inner join servicio s on t.servicioId=s.id where t.id=" + id;
            //String cmd = "select * from vinder.dbo.tip t , vinder.dbo.servicio s where t.servicioId=s.id and t.id=14";
            String cmd = "select * from tip where id=15";
            using (SqlConnection connection = new SqlConnection("Data Source=TITAN\\SQLEXPRESS;Initial Catalog=vinder;Integrated Security=True"))
            {
                SqlCommand command = new SqlCommand(cmd, connection);
                command.CommandType = CommandType.Text;
                command.CommandTimeout = 120;

                connection.Open();
                using (SqlDataReader myReader = command.ExecuteReader())
                {
                    if (myReader.Read())
                    {
                        //tip = FillDataRecord(myReader);
                        IDataRecord record = myReader;
                    }
                    myReader.Close();
                }
                connection.Close();
            }
            return servicio;
        }

        public static List<Servicio> getTodosLosServicios()
        {
            //TODO: implement me
            return null;
        }

        public static int salvar(Servicio servicio)
        {
            //TODO: implement me
            return 0;
        }

        public static bool borrar(int id)
        {
            //TODO: implement me
            return false;
        }

    }
}
